import React, { Component } from 'react';
import { observer, inject } from 'mobx-react';
import { withRouter } from 'react-router-dom';

import { Comment } from 'weaver-mobile-page';
import { toJS } from 'mobx';

@withRouter
@inject( 'wfCommunicateStore')
@observer
export default class ContentList extends Component {
 
  openLink = (href) => {
    window.openLink(href);
  }

  operateAttachList = (type, data) => {
    this.openLink(data.url);
  }

  communicationPage = () => {
    const { wfCommunicateStore } = this.props;
    let { allComment, relatedMeComment, page } = wfCommunicateStore;
    const renderRightTop = (data) => {
      return (
        <div className={'talk-renderRightTop'}>
            <span className={'talk-renderRight-floor'}>#{data.floorNum}</span>
      </div>
      )
    }
    return (
      <Comment
        store={page === 'allCommunications'? allComment : relatedMeComment}
        hasInitialListSize //首页加载数据默认条数为10条
        showPosition={data => console.log('data', data)}
        renderRightTop={renderRightTop}
        operateAttachList={this.operateAttachList}
      />)
  }
  render() {
    const { wfCommunicateStore } = this.props;
    let {  page } = wfCommunicateStore;
    return (
      <div style={{height: '100%'}}>
        {page === 'allCommunications' && this.communicationPage()}
        {page === 'relatedMe' && this.communicationPage()}
       
      </div>
    );
  }
}





